home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / Sherlock 2.0 / DevLibSrc / Main_DevLib / LIBobj.h < prev    next >
Text File  |  1995-11-16  |  3KB  |  92 lines

  1. /*
  2.     List: header file for object routines.
  3.     
  4.     source:  LIBobj.h
  5.     started: December 13, 1993.
  6.     version:
  7.         November 14, 1995.
  8.             `obj_free_macro' expands to `lib_free' instead of `free'.
  9.         September 25, 1995.
  10.             Removed unused title param from obj_dump_stats.
  11.         December 22, 1993.
  12.             Added obj_new_var_tag_macro.
  13. */
  14.  
  15. #ifndef LIBobj_h_
  16. #define LIBobj_h_
  17.  
  18. #pragma once
  19.  
  20.     /* Constants. */
  21.     
  22. #define OBJ_MAGIC 0x1234    /* Magic value for validity check.    */
  23. #define OBJ_HEADER_SIZE        4        /* Size of obj_prot field. */
  24. #define OBJ_TRAILER_SIZE    8        /* Size of obj_trailer field. */
  25. #define OBJ_FILLER            0xA3    /* Fill value for fields. */
  26.  
  27.     /* Structures. */
  28.  
  29. typedef struct type_des_struct type_des;
  30. typedef struct obj_head_struct obj_head;
  31.  
  32. /*
  33.     obj_new_var_tag_macro is used when the tag parameter is not a string constant.
  34. */
  35. #ifdef PRODUCTION
  36.  
  37.     #define obj_new_macro(the_mem, size, tag) the_mem = obj_new(size)
  38.     #define obj_new_var_tag_macro(the_mem, size, tag) the_mem = obj_new(size)
  39.     #define obj_free_macro(the_mem) lib_free(the_mem)
  40.  
  41. #else
  42.  
  43.     struct type_des_struct {
  44.         char *        type_name;        /* Print name of this type. */
  45.         type_des *    type_alpha;        /* Alphabetically next type descriptor. */
  46.         obj_head *    type_tlist;        /* List of all object of this type. */
  47.         long        type_nmax;        /* Object size statistics. */
  48.         long        type_nnet;
  49.         long        type_ntot;
  50.         long        type_cmax;        /* Alloc/free (call) statistics. */
  51.         long        type_cnet;
  52.         long        type_ctot;
  53.         int            type_attrib;    /* Attributes of this type. */
  54.         int            type_magic;        /* Must be OBJ_MAGIC. */
  55.     };
  56.  
  57.     struct obj_head_struct {
  58.         type_des *    obj_type;            /* Object type. */
  59.         char *        obj_dtag;            /* Data tag. */
  60.         obj_head *    obj_olist;            /* list of all objects in allocation order. */
  61.         obj_head *    obj_tlist;            /* list of all objects of this type. */
  62.         long        obj_size;            /* Size of object. (must be long!) */
  63.         char obj_prot[OBJ_HEADER_SIZE];    /* Header protection.    */
  64.     };
  65.     
  66.     #define obj_new_macro(the_mem, size, tag) \
  67.         {static type_des * tp_ = NULL; the_mem = obj_new_db(size, tag, &tp_);}
  68.     #define obj_new_var_tag_macro(the_mem, size, tag) \
  69.         {type_des * tp_ = NULL; the_mem = obj_new_db(size, tag, &tp_);}
  70.     #define obj_free_macro(the_mem) obj_free_db(the_mem)
  71.  
  72. #endif
  73.  
  74. /*
  75.     Function prototypes.
  76. */
  77.     void obj_test (void);
  78.  
  79. #ifdef PRODUCTION
  80.     void *    obj_new    (size_t size);
  81. #else
  82.     void    obj_check_all    (void);
  83.     void    obj_check_object(void *o);
  84.     void    obj_dump_objects(void);
  85.     void    obj_dump_stats    (void);
  86.     void    obj_free_db        (void * obj);
  87.     void *    obj_new            (size_t size);
  88.     void *    obj_new_db        (size_t size, char * tag, type_des ** tp);
  89. #endif
  90.  
  91. #endif /* LIBobj_h_ */
  92.